import { reactive } from 'vue';
import type { IPerson } from "@/myTypes";
import { getPersonListApi } from "~/person";

export const roles = [
    {
        label:"超级管理员",
        value:0
    },
    {
        label:"运营",
        value:1
    },
    {
        label:"运营助理",
        value:2
    },
    {
        label:"轮播图员",
        value:3
    }
]

export function usePersonList() {
    
    const persons: IPerson[] = reactive([]);

    // 获取操作人员列表
    const getPersonList = () => {
        getPersonListApi()
            .then((res: any) => {
                if (res.data.code === "200") {
                    persons.length = 0;
                    persons.push(...res.data.data);
                }
            })
    }

    getPersonList();

    return {persons,getPersonList};

}
